package domain

import (
	"gorm.io/gorm"
	"time"
)

type Assets struct {
	ID          int64          `json:"id"`
	Name        string         `json:"name"`
	Mime        string         `json:"mime"`
	Path        string         `json:"path"`
	IsForeign   bool           `json:"is_foreign" gorm:"default:false"`
	IsDirectory bool           `json:"is_directory" gorm:"default:false"`
	ParentID    *int64         `json:"-"`
	OwnerID     *int64         `json:"-"`
	Parent      *Assets        `json:"parent" gorm:"foreignKey:ParentID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"`
	Children    []Assets       `json:"children" gorm:"foreignKey:ParentID;"`
	OwnerClub   []*Club        `json:"owner_club" gorm:"many2many:club_assets"`
	Description *string        `json:"description"`
	CreatedAt   time.Time      `json:"created_at" `
	UpdatedAt   time.Time      `json:"updated_at" `
	DeletedAt   gorm.DeletedAt `gorm:"index"`
}
type AssetsDTO struct {
	ID          int64       `json:"id"`
	Name        string      `json:"name"`
	Mime        string      `json:"mime"`
	Path        string      `json:"path"`
	IsForeign   bool        `json:"is_foreign" gorm:"default:false"`
	IsDirectory bool        `json:"is_directory" gorm:"default:false"`
	ParentID    *int64      `json:"-"`
	OwnerID     *int64      `json:"-"`
	Parent      *AssetsDTO  `json:"parent" gorm:"foreignKey:ParentID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"`
	Children    []AssetsDTO `json:"children" gorm:"foreignKey:ParentID;"`
	OwnerClub   []*ClubDTO  `json:"owner_club" gorm:"many2many:club_assets"`
	Description *string     `json:"description"`
	CreatedAt   time.Time   `json:"created_at" `
	UpdatedAt   time.Time   `json:"updated_at" `
}
